<template>
  <div class="svg-icon">
    <!-- <use :xlink:href="require('../../icons/svg/404.svg')"></use> -->
    <img
      class="svg-icon"
      :src="resolveSvgIcon"
      alt=""
    />
  </div>
</template>
<script setup>
import { defineProps, computed } from "vue";
const props = defineProps({
  icon: {
    type: String,
    required: true,
  },
});

const iconName = computed(() => {
  return `#icon-${props.icon}`;
});

const resolveSvgIcon = computed(() => {
  try {
    return new URL(`/src/icons/svg/${props.icon}.svg`, import.meta.url).href;
  } catch (error) {
    console.error(`Failed to resolve SVG icon for ${props.icon}`, error);
    return null;
  }
});
</script>
<style lang="scss" scoped>
.svg-icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
</style>
